import 'package:flutter/material.dart';
import 'package:simple_animations/simple_animations.dart';

enum AniProps{color}
class AnimatedBackground extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final tween = TimelineTween<AniProps>()..addScene(
      begin: const Duration(milliseconds: 0),
      duration: const Duration(seconds: 3)
    ).animate(AniProps.color, tween: ColorTween(begin: const Color(0xffD38312), end: Colors.lightBlue.shade900),
    )..addScene(
        begin: const Duration(milliseconds: 3),
        duration: const Duration(seconds: 3)
    ).animate(AniProps.color, tween: ColorTween(begin:const Color(0xffA83279),
      end: Colors.blue.shade600,),
    );
    //   ([
    //   Track('color1').add(
    //     Duration(seconds: 3),
    //     ColorTween(begin: Color(0xffD38312), end: Colors.lightBlue.shade900),
    //   ),
    //   Track('color2').add(
    //     Duration(seconds: 3),
    //     ColorTween(
    //       begin: Color(0xffA83279),
    //       end: Colors.blue.shade600,
    //     ),
    //   ),
    // ]);
    return Container(
      child: PlayAnimation<TimelineValue<AniProps>>(
        tween: tween,
        duration: tween.duration,
        builder: (context,child,value){
          return Container(
            color: value.get(AniProps.color),
          );
        },
      ),
    );
    // return ControlledAnimation(
    //     playback: Playback.MIRROR,
    //     tween: tween,
    //     duration: tween.duration,
    //     builder: (context, animation) {
    //       return Container(
    //         decoration: BoxDecoration(
    //           gradient: LinearGradient(
    //             colors: [animation['color1'], animation['color2']],
    //             begin: Alignment.topCenter,
    //             end: Alignment.bottomCenter,
    //           ),
    //         ),
    //       );
    //     });
  }
}